package com.hcj.front.entity.enums;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * 测试枚举
 */
public enum AgeEnum implements IEnum {
    ONE(1, "一岁"),
    TWO(2, "二岁");

    private int value;
    private String desc;
    private  Map map;

    AgeEnum(final int value, final String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public Serializable getValue() {
        return this.value;
    }

    public String getDesc(){
        return this.desc;
    }

    @JsonValue
    public Map getMap() {
        Map<String, Object> map = new HashMap<String, Object>(3);
        map.put("name", this.name());
        map.put("id", value);
        map.put("desc", desc);
        return  map;
    }

    public void setMap(Map map) {
        this.map = map;
    }

    public static AgeEnum[] getJson(){
        AgeEnum[] list = AgeEnum.values();
        return list;
    }

//    @Override
//    public String toString() {
//        return JSONObject.toJSONString(this.toString());
//    }
}
